package com.admin.util.face;


import com.data.entity.enums.ErrorCodeEnum;

public class Results {

    public static <T> ResultFace<T> newSuccessResult(T data) {
        return newResult(data, "注册成功，已添加到业主库！", true,0);
    }

    public static <T> ResultFace<T> newFailedResult(String message) {
        return newResult(null, message, false,-10000);
    }

    public static <T> ResultFace<T> newFailedResult(Integer code, String message) {
        return newResult(null, message, false, code);
    }

    public static <T> ResultFace<T> newFailedResult(ErrorCodeEnum errorCodeEnum) {
        return newResult(null, errorCodeEnum.getDescription(), false, errorCodeEnum.getCode());
    }

    public static <T> ResultFace<T> newResult(T data, String message, boolean success, Integer code) {
        ResultFace resultFace = new ResultFace();
        resultFace.setData(data);
        resultFace.setCode(code);
        resultFace.setSuccess(success);
        resultFace.setMessage(message);
        return resultFace;
    }
}
